#include "main.h"
#include "led.h"
#include "usart.h"
#include "rcc.h"
#include "timer_it.h"
#include "timer_pwm.h"
#include "spi.h"
#include "iic.h"
#include "st7735s.h"
#include "oled.h"

int main(void)
{
    HAL_Init();
    SystemClock_Config();
    app_led_gpio_init();
    Usart_Config(115200);
    timer16_it_init();
    timer1_pwm_init();

    uint8_t Sysclock = HAL_RCC_GetSysClockFreq() / 1000000;
    printf("SysClock:%d MHz\n", Sysclock);

    // LCD测试
    // software_spi_init();
    // st7735s_lcd_init();
    // st7735s_lcd_clear(COLOR_WHITE);
    // st7735s_lcd_fill_color(0, 0, 40, 40, COLOR_RED);
    // st7735s_lcd_draw_line(0, 0, 100, 50, COLOR_GREEN);
    // st7735s_lcd_draw_rectangle(0, 0, 100, 50, COLOR_WHITE);
    // st7735s_lcd_draw_circle(80, 40, 40, COLOR_BLUE);

    // 0.96 OLED测试
    software_iic_init();
    OLED_Init();                                //OLED 显示初始化
    OLED_Clear();                               //OLED 清空屏幕
    OLED_ShowString(1,3,"Hello World!");        //在第4行第3列的位置显示显示字符串Hello World!
    OLED_ShowNum(2,1,888,3);
    OLED_ShowSignedNum(2,5,333,3);
    OLED_ShowSignedNum(2,10,-666,3);
    OLED_ShowHexNum(4,1,0xffa,3);
    OLED_ShowBinNum(4,8,0xff,8);
    OLED_ShowChar(3,10,'A');

    while (1)
    {
        // app_led_sate_set(E_LED_TOGGLE);
        // HAL_Delay(50);
        // // 获取当前占空比
        // uint8_t current_duty = timer1_get_pwm_duty();
        // printf("current = %d\n", current_duty);
        // lcd_burn_test(0);
    }
}
